import { App } from 'vue';
import { SET_LOCAL_STATE, SET_STORE_STATE } from './actionType';
import store from './index';

const set = <T>(name: string, value: T): void => {
	const options: ISetStoreStateOptions<T> = {
		name,
		value
	}
	store.dispatch(SET_STORE_STATE, options);
}

const local = <T>(name: string, value: T): void => {
	const options: ISetStoreStateOptions<T> = {
		name,
		value
	}
	store.dispatch(SET_LOCAL_STATE, options);
}




const install = (app: App): void => {
	uni.store = {
		set,
		local
	}
}

export default {
	install
}